﻿using Common.Communal;
using ERP.Domain.System;
using MediatR;
using SqlSugar;
using System.Api.Read.Applications.Commands.Organizes;

namespace System.Api.Read.Applications.CommandHandlers.Organizes
{
    public class UserQueryCommandHandler : IRequestHandler<UserQueryCommand, ApiResult<List<User>>>
    {
        private readonly ISqlSugarClient sqlSugar;

        public UserQueryCommandHandler(ISqlSugarClient sqlSugar)
        {
            this.sqlSugar = sqlSugar;
        }
        public Task<ApiResult<List<User>>> Handle(UserQueryCommand request, CancellationToken cancellationToken)
        {
            ApiResult<List<User>> result = new ApiResult<List<User>>();
            var res = sqlSugar.Queryable<User>().ToList();
            result.Success(res, "用户获取成功");
            return Task.FromResult(result);
        }
    }
}
